<?php
require_once("common.inc.php");

if(isset($_POST["submit"])){
  $username=$_POST[ "Username"];
  $password=$_POST["Password"];
  $intro = $_POST["Intro"]; 
  $createTime = date_format(new DateTime(),'Y-m-d H:i:s');
  $sql = "INSERT INTO `account`( `Username` , `Password` , `Intro`)VALUES( '$username','$password',' $intro')";
  $conn= createDb();
  $conn->query($sql);
  if($conn->error) die($conn->error);
  $id = $conn->insert_id;
  if(isset($_FILES["face"]))
    {
      $faceInfo = $_FILES["face"];
      $dest =__DIR__."/faces/$id.jpg";
      move_uploaded_file($faceInfo["tmp_name"],$dest);  
    }else{
      $dest =__DIR__."/faces/face.jpg";
      $src = __DIR__."/default-face.jpg";
      copy($src,$dest);
    }


}
?>
<?php require_once("header.inc.php");?>

<form action="" enctype="multipart/form-data" method= "post" class="dataset">
    <div class="field">
      <label>用户名</label><input name= "Username" type="text" placeholder="请输入用户名"/>
    </div>
    <div class="field">
      <label>密码</label><input name="Password" type="password" value=""/>
    </div>
    <div class="field">
      <label>头像</label><input name="face" type="file" title="上传头像"/>
    </div>

    <div class="field">
      <label>自我介绍</label>
      <textarea name="Intro"cols= "20" rows="5">123</textarea>
    </div>
    <div class="actions">
      <input type="reset" name="reset" value="重设"/>
      <input type="submit" name="submit" value="提交"/>
    </div>
</form>
<?php require_once("footer.inc.php");?>